package ui.component {

	import flash.display.Sprite;
	
	public class StarRate extends Sprite {
		
		private var starList:Array;

		public function StarRate() {
			super();
			
			starList = new Array();
			var star:Star;
			for (var i:int = 0; i<5; i++) {
				star = new Star();
				star.x = 14 * i;
				star.y = 0;
				addChild(star);
				starList.push(star);
			}
		}
		
		public function update(value:Number):void {
			value = 4.5;
			clear();
			var star:Star;
			for (var i:int = 0; i<Math.ceil(value); i++) {
				star = starList[i];
				star.update(value - 0.5 > i);
			}
		}
		
		public function clear():void {
			var star:Star;
			for (var i:int = 0; i<5; i++) {
				star = starList[i];
				star.clear();
			}
		}
	}
}

import flash.display.Bitmap;

import globals.Global;

class Star extends Bitmap {
	
	
	public function Star() {
		
	}
	
	public function update(full:Boolean):void {
		if (full) {
			bitmapData = Global.assetsManager.getAssetsAsBitmapData("star");
		} else {
			bitmapData = Global.assetsManager.getAssetsAsBitmapData("star_half");
		}
	}
	
	public function clear():void {
		bitmapData = null;
	}
}